package com.lcj.service.impl;

import com.lcj.dao.UserDao;
import com.lcj.entity.User;
import com.lcj.exception.UserNotFoundException;
import com.lcj.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("userService")
public class UserServiceImpl implements UserService {
    @Autowired
    UserDao userDao;
    @Override
    public User dologin(String username, String password) {
        User user = userDao.selectUserByName(username);
        if(null!=user)
        {
            if(user.getPassword().equals(password))
            {
                return user;
            }
            throw new UserNotFoundException("密码不正确");
        }
        throw new UserNotFoundException("用户名不存在");
    }
}
